import qrcode
from PIL import Image, ImageDraw

qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data('Some data')
qr.make(fit=True)

# 创建一个空的图像
qr_img = Image.new('RGB', (290, 290), 'white')
draw = ImageDraw.Draw(qr_img)

# 将二维码数据绘制到图像上
for x in range(qr.modules_count):
    for y in range(qr.modules_count):
        if qr.modules[x][y]:
            draw.rectangle((x * 10, y * 10, x * 10 + 10 - 1, y * 10 + 10 - 1), fill='black')

print(qr_img.width, qr_img.height)
qr_img.show()